﻿@model IEnumerable<DefeatEpidemic.Models.Community>

<div class="layui-row">
    <span class="layui-breadcrumb">
        <a href="~/home/index">首页</a>
        <a href="~/communities/Index">社区管理</a>
        <a>
            <cite>社区列表</cite>
        </a>
    </span>
    <a class="layui-btn layui-btn-xs" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon layui-icon-refresh-1" style="line-height:25px;font-size: 10px"></i>
    </a>
</div>
<hr />
<p>
    <div class="layui-form-item">
        <label class="layui-form-label">检索</label>
        <div class="layui-input-inline">
            <input type="text" id="community_name" class="layui-input" placeholder="请输入社区名称" />
        </div>
        <a href="javascript:;" id="btn_search" class="layui-btn layui-btn-normal">检索</a>
        <a asp-action="Create" class="layui-btn">创建社区</a>
    </div>
</p>
<table class="layui-table" id="table"></table>
<script type="text/html" id="operationTpl">
    <a href="@Url.Action("Edit")/{{d.id}}" class="layui-btn layui-btn-normal">编辑</a>
    <a href="javascript:;" onclick="del('{{ d.id }}')" class="layui-btn layui-btn-danger">删除</a>
    @*<a href="@Url.Action("Create","Applications")?family_id={{ d.id }}" id="apply_{{ d.id }}" class="layui-btn">申请出行</a>*@
</script>
<script type="text/html" id="statusTpl">
    {{# if(d.status==0){}}
    <span style="color:#5FB878;">未发现病例</span>
    {{# } }}
    {{# if(d.status==1){}}
    <span style="color:#ff0000;">有确诊人员</span>
    {{# } }}
</script>

<script>
    var token = $('@Html.AntiForgeryToken()').val();
    var params = {
        url: '@Url.Action("GetList")',
        elem: '#table',
        where: '',
        size: 'lg',
        page: true,
        cols: [ //表头
            //, { field: 'id', title: 'ID', sort: true, fixed: 'left' }
            { title: '序号', templet: "#indexTpl", width: 70 }
            , { field: 'name', title: '小区名称' }
            , { field: 'province', title: '省' }
            , { field: 'city', title: '市' }
            , { field: 'area', title: '区县' }
            , { field: 'detail', title: '详细地址' }
            , { field: 'labelNumber', title: '编号' }
            , { title: '状态', templet: '#statusTpl' }
            , { field: 'created_at', title: '创建时间' }
            , { title: '操作', templet: '#operationTpl' }
        ],
        height: 630
    };
    getTable(params);

    //检索
    $("#btn_search").click(function () {
        var name = $("#community_name").val();
        var where = {
            'name': name
        };
        params.where = where;
        getTable(params);
    })

    function del(id) {
        UpdateItem("@Url.Action("Delete")", { "id": id, "__RequestVerificationToken": token }, "确定要删除该条记录吗");
    }
</script>
